Skip to content

core: unify lua and :set option handling#1349

Open
rnpnr wants to merge 1 commit intomartanne:masterfrom
rnpnr:lua_option_merge
Open

core: unify lua and :set option handling#1349
rnpnr wants to merge 1 commit intomartanne:masterfrom
rnpnr:lua_option_merge

Conversation

@rnpnr
Copy link
Copy Markdown
Collaborator

@rnpnr rnpnr commented May 8, 2026

The only thing that needs to be different about these paths is how the value that will be assigned to option is obtained. When the value comes from lua we can ask lua directly for the expected type but when it comes from :set we need to parse it ourselves.

Besides that, lookup of the option, and setting of the option should not be using different codepaths. By combining them we no longer need worry about modifying multiple places in the code to add an option or update its handling.

The addition of a vis_option_get() helper should also facilitate easy building of a full table of option values to pass to lua but that is not implemented here. Furthermore the C-API was updated to add a VisOptionGetFunction pointer to the option registration which would allow custom options to be included in the table but since addition to lua would require breaking the existing API it needs to be further discussed.

@rnpnr
Copy link
Copy Markdown
Collaborator Author

rnpnr commented May 8, 2026

With respect to having a get function pointer for custom options I would like feedback from plugin authors who register custom options.

@fischerling I know you register a spelllang option in vis-spellcheck (and I'm sure vis-lspc has some as well). If we were to modify the way win.options works so that it actually pushes a table with all the current options and values already filled a get callback would allow for the value of spelllang to be included in the table. What are your thoughts on this?

I do believe the additional function pointer is valuable on the C side because it would be required for a possible C plugin interaction (the rest of vis is already kind of set up for this even though its not implemented).

@rnpnr rnpnr force-pushed the lua_option_merge branch 3 times, most recently from 391e8fe to 23c5b38 Compare May 10, 2026 01:14
The only thing that needs to be different about these paths is how
the value that will be assigned to option is obtained. When the
value comes from lua we can ask lua directly for the expected type
but when it comes from :set we need to parse it ourselves.

Besides that lookup of the option, and setting of option should
not be using different codepaths. By combining them we no longer
need worry about modifying multiple places in the code to add an
option or update its handling.

The addition of a vis_option_get() helper should also facilitate
easy building of a full table of option values to pass to lua but
that is not implemented here. Furthermore the C-API was updated to
add a VisOptionGetFunction pointer to the option registration
which would allow custom options to be included in the table but
since addition to lua would require breaking the existing API it
needs to be further discussed.
@rnpnr rnpnr force-pushed the lua_option_merge branch from 23c5b38 to 9bd771c Compare May 10, 2026 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant